import { ref, h } from "vue";
import { render } from "@/utils";
import multiLine from "common/multiLine.vue";
import usageRate from "common/usageRate.vue";
import TagStatus from "@/components/TagStatus/index.vue";
import LinkText from "@/components/LinkText/index.vue";
import systemType from "common/systemType.vue";

export const columns = [
  {
    title: "名称",
    dataIndex: "name",
    width: 230,
    tooltip: true,
    ellipsis: true,
    fixed: "left",
    render: ({ record }) =>
      h(LinkText, {
        label: record?.name,
        to: `/computing-mgmt/computing-node/detail/${record?.id}?name=${record?.name}&resId=${record?.resourceId}&type=${record?.resourceType}&menu=host`,
      }),
  },
  {
    title: "品牌型号",
    dataIndex: "model",
    tooltip: true,
    ellipsis: true,
    width: 180,
    render,
  },
  {
    title: "状态",
    dataIndex: "status",
    width: 90,
    render: ({ record }) => h(TagStatus, { type: record.status }),
  },
  {
    title: "集群",
    dataIndex: "clusterName",
    tooltip: true,
    ellipsis: true,
    width: 200,
    render,
  },
  { title: "运行时间", dataIndex: "runtime", width: 90, render },
  {
    title: "启用",
    dataIndex: "enabled",
    slotName: "enabled",
    width: 60,
  },
  {
    title: "机柜位置/机柜编号",
    dataIndex: "coordinate",
    width: 200,
    render: ({ record }) => h(systemType, { type:record?.coordinate,content:record?.cabinetNumber,icon:'ubuntu'  }),
    // render: ({ record }) =>
    //   h(LinkText, {
    //     label: record?.coordinate,
    //     desc: record?.cabinetNumber,
    //   }),
  },
  {
    title: "带内IP",
    dataIndex: "inBandIp",
    width: 150,
    render: ({ record }) => h(multiLine, { list: record.inBandIp }),
  },
  {
    title: "带外IP",
    dataIndex: "outBandIp",
    width: 150,
    render,
  },
  {
    title: "CPU使用率",
    dataIndex: "cpu",
    width: 180,
    render: ({ record }) =>
      h(usageRate, {
        total: record?.totalCpuCores,
        used: record?.usedCpuCores,
      }),
  },
  {
    title: "内存使用率",
    dataIndex: "memory",
    width: 180,
    render: ({ record }) =>
      h(usageRate, { total: record?.totalMemory, used: record?.usedMemory }),
  },
  {
    title: "存储使用率",
    dataIndex: "disk",
    width: 180,
    render: ({ record }) =>
      h(usageRate, { total: record?.totalDisk, used: record?.usedDisk }),
  },
  // {
  //   title: "操作",
  //   width: 120,
  //   dataIndex: "action",
  //   fixed: "right",
  //   slotName: "action"
  // },
]
